package hbt;

import org.hibernate.SessionFactory;
import org.hibernate.cfg.AnnotationConfiguration;


import bean.*;

public class HibernateUtil
{
    private static final SessionFactory sessionFactory;
    static
    {
        try
        {
        	 AnnotationConfiguration config = new AnnotationConfiguration();
        	 config.addAnnotatedClass(Usuario.class);
        	 config.addAnnotatedClass(Departamento.class);
        	 config.addAnnotatedClass(Empleado.class);
        	 config.addAnnotatedClass(Secretaria.class);
        	 config.addAnnotatedClass(TipoDocumento.class);
        	 config.addAnnotatedClass(Movimiento.class);
        	 config.addAnnotatedClass(Expediente.class);
       	 
        	        	
        	 sessionFactory = config.buildSessionFactory();
        }
        catch (Throwable ex)
        {
            System.err.println("Error en el inicio de SessionFactory: " + ex);
            throw new ExceptionInInitializerError(ex);
        }
    }
 
    public static SessionFactory getSessionFactory()
    {
        return sessionFactory;
    }
}
